#include<bits/stdc++.h>
using namespace std;
int n,a[200004],cnt=0;
struct node{
	int h;
	vector<int> f;
};
node q[200005];
int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%d",&n);
	a[0]=-1;
	q[0].h=1;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]==a[i-1])q[cnt].h++,q[cnt].f.push_back(i);
		else{
			q[++cnt].h=1;
			q[cnt].f.push_back(i);
		}
	}
	//for(int i=1;i<=cnt;i++)cout<<q[i].h<<endl;
	int qq=cnt;
	while(qq){
		for(int i=1;i<=cnt;i++){
			if(q[i].h){
				printf("%d ",q[i].f[0]);
				q[i].f.erase(q[i].f.begin(),q[i].f.begin()+1);
				q[i].h--;
			}
		}
		printf("\n");
		for(int i=1;i<=cnt;i++){
			if(!q[i-1].h&&q[i].h){
				qq--;
				for(int j=cnt-1;j>0;j--){
					if(q[j].h&&(cnt-j)%2==0){
						q[i].h=0;
						int y=q[i].f.size();
						for(int k=0;k<y;k++){
							q[j].f.push_back(q[i].f[k]);
							q[j].h++;
						}
					}
				}
			}
		}
		//system("pause");
	}
	return 0;
}

